﻿using System;
using System.Collections.Generic;
using Castle.ActiveRecord;
using CostTrade.Contract;
using CostTrade.Core.Data;
using Natrue.Popedom.Organizational;
using Natrue.Data.FastMapping;

namespace CostTrade.BusinessLayer
{
    /// <summary>
    /// 出口单
    /// </summary>
    [ActiveRecord("tbExportOrder"), Serializable]
    public class ExportOrder : CBBase
    {
        private readonly Guid primaryKey = Guid.NewGuid();
        [PrimaryKey(PrimaryKeyType.Assigned, "ROWGUID", Access = PropertyAccess.NosetterCamelcase),Mark("")]
        public override Guid PrimaryKey
        {
            get { return primaryKey; }
        }

        /// <summary>
        /// 出口单编号
        /// </summary>
        private string exportId;
        /// <summary>
        /// 入口单号
        /// </summary>
        private string importId;
        /// <summary>
        /// 订单内容
        /// </summary>
        private IList<ExportWares> orderWares = new List<ExportWares>();
        /// <summary>
        /// 客户联系方式
        /// </summary>
        private string clientContent;
        /// <summary>
        /// 下单人
        /// </summary>
        private Employee makeOrder;
        /// <summary>
        /// 下单日期
        /// </summary>
        private DateTime makeOrderDate = DateTime.Now;
        /// <summary>
        /// 预计出货日期
        /// </summary>
        private DateTime shipmentDate;
        /// <summary>
        /// 发货日期
        /// </summary>
        private DateTime sendGoodsDate;
        /// <summary>
        /// 商品总数
        /// </summary>
        private int waresCount;
        /// <summary>
        /// 出口单状态
        /// </summary>
        private ExpImpOrderState orderState;
        /// <summary>
        /// 收货人
        /// </summary>
        private Employee reviceGoodser;
        /// <summary>
        /// 收货公司
        /// </summary>
        private Company reviceCompany;
        /// <summary>
        /// 出口单总价
        /// </summary>
        private double exportValues;
        /// <summary>
        /// 出口汇率
        /// </summary>
        private ExchangeRate exchange;
        /// <summary>
        /// 入口总价
        /// </summary>
        private double importTotalPrice;
        /// <summary>
        /// 入口汇率
        /// </summary>
        private ExchangeRate importExchange;
        /// <summary>
        /// 出入口总差价
        /// </summary>
        private double priceDifference;

        /// <summary>
        /// 出口单编号
        /// </summary>
        [Property, Mark("出口单编号", IsNotNull = true)]
        public string ExportId
        {
            get { return exportId; }
            set { exportId = value; }
        }

        /// <summary>
        /// 入口单号
        /// </summary>
        [Property, Mark("入口单号",IsNotNull = true)]
        public string ImportId
        {
            get { return importId; }
            set { importId = value; }
        }

        /// <summary>
        /// 订单内容
        /// </summary>
        [HasAndBelongsToMany(typeof(ExportWares),ColumnKey = "ExportOrderKey",ColumnRef = "ExportWareKey", Table = "ExportOrderAndWares",Access = PropertyAccess.NosetterCamelcase),Mark("订单内容")]
        public IList<ExportWares> OrderWares
        {
            get { return orderWares; }
        }

        /// <summary>
        /// 客户联系方式
        /// </summary>
        [Property, Mark("客户联系方式")]
        public string ClientContent
        {
            get { return clientContent; }
            set { clientContent = value; }
        }

        /// <summary>
        /// 下单人
        /// </summary>
        [BelongsTo, Mark("下单人")]
        public Employee MakeOrder
        {
            get { return makeOrder; }
            set { makeOrder = value; }
        }

        /// <summary>
        /// 下单日期
        /// </summary>
        [Property, Mark("下单日期")]
        public DateTime MakeOrderDate
        {
            get { return makeOrderDate; }
            set { makeOrderDate = value; }
        }

        /// <summary>
        /// 预计出货日期
        /// </summary>
        [Property, Mark("预计出货日期")]
        public DateTime ShipmentDate
        {
            get { return shipmentDate; }
            set { shipmentDate = value; }
        }

        /// <summary>
        /// 发货日期
        /// </summary>
        [Property, Mark("发货日期")]
        public DateTime SendGoodsDate
        {
            get { return sendGoodsDate; }
            set { sendGoodsDate = value; }
        }

        /// <summary>
        /// 商品总数
        /// </summary>
        [Property, Mark("商品总数")]
        public int WaresCount
        {
            get { return waresCount; }
            set { waresCount = value; }
        }

        /// <summary>
        /// 出口单状态
        /// </summary>
        [Property, Mark("出口单状态")]
        public ExpImpOrderState OrderState
        {
            get { return orderState; }
            set { orderState = value; }
        }

        /// <summary>
        /// 收货人
        /// </summary>
        [BelongsTo, Mark("收货人")]
        public Employee ReviceGoodser
        {
            get { return reviceGoodser; }
            set { reviceGoodser = value; }
        }

        /// <summary>
        /// 收货公司
        /// </summary>
        [BelongsTo, Mark("收货公司")]
        public Company ReviceCompany
        {
            get { return reviceCompany; }
            set { reviceCompany = value; }
        }

        /// <summary>
        /// 出口单总价
        /// </summary>
        [Property, Mark("出口单总价")]
        public double ExportValues
        {
            get { return exportValues; }
            set { exportValues = value; }
        }

        /// <summary>
        /// 出口汇率
        /// </summary>
        [BelongsTo, Mark("出口汇率")]
        public ExchangeRate Exchange
        {
            get { return exchange; }
            set { exchange = value; }
        }

        /// <summary>
        /// 入口总价
        /// </summary>
        [Property, Mark("入口总价")]
        public double ImportTotalPrice
        {
            get { return importTotalPrice; }
            set { importTotalPrice = value; }
        }

        /// <summary>
        /// 入口汇率
        /// </summary>
        [BelongsTo, Mark("入口汇率")]
        public ExchangeRate ImportExchange
        {
            get { return importExchange; }
            set { importExchange = value; }
        }

        /// <summary>
        /// 出入口总差价
        /// </summary>
        [Property, Mark("出入口总差价")]
        public double PriceDifference
        {
            get { return priceDifference; }
            set { priceDifference = value; }
        }
    }
}